package com.hkq.mall.member.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 1. 引入spring-cloud-starter-alibaba-nacos-config依赖
 * 2. bootstrap.properties
 *      spring.application.name=gulimall-member
 *      spring.cloud.nacos.config.server-addr=127.0.0.1:8848
 * 3. @RefreshScope动态刷新配置，@Value(${xxx})获取配置
 * 4. localhost:8848  配置列表public空间下新增dataId=gulimall-member.properties，内容xxx=yyy
 */
@RestController
@RefreshScope
public class TestNacosConfigController {
    @Value("${member.sys.username}")
    private String sysUsername;
    @GetMapping("/test/nacos/config")
    public String testNacosConfig() {
        return sysUsername;
    }
}
